
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>dislocation_SDVPN calculation style &#8212; iprPy 0.10.2 documentation</title>
    <link rel="stylesheet" href="../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
    <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true, "ignoreClass": "document", "processClass": "math|output_area"}})</script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="dislocation_monopole calculation style" href="dislocation_monopole.html" />
    <link rel="prev" title="diatom_scan calculation style" href="diatom_scan.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="dislocation_monopole.html" title="dislocation_monopole calculation style"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="diatom_scan.html" title="diatom_scan calculation style"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">iprPy 0.10.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../notebook_styles.html" accesskey="U">Jupyter Demonstration Notebooks</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  
<style>
/* CSS for nbsphinx extension */

/* remove conflicting styling from Sphinx themes */
div.nbinput.container,
div.nbinput.container div.prompt,
div.nbinput.container div.input_area,
div.nbinput.container div[class*=highlight],
div.nbinput.container div[class*=highlight] pre,
div.nboutput.container,
div.nboutput.container div.prompt,
div.nboutput.container div.output_area,
div.nboutput.container div[class*=highlight],
div.nboutput.container div[class*=highlight] pre {
    background: none;
    border: none;
    padding: 0 0;
    margin: 0;
    box-shadow: none;
}

/* avoid gaps between output lines */
div.nboutput.container div[class*=highlight] pre {
    line-height: normal;
}

/* input/output containers */
div.nbinput.container,
div.nboutput.container {
    display: -webkit-flex;
    display: flex;
    align-items: flex-start;
    margin: 0;
    width: 100%;
}
@media (max-width: 540px) {
    div.nbinput.container,
    div.nboutput.container {
        flex-direction: column;
    }
}

/* input container */
div.nbinput.container {
    padding-top: 5px;
}

/* last container */
div.nblast.container {
    padding-bottom: 5px;
}

/* input prompt */
div.nbinput.container div.prompt pre {
    color: #307FC1;
}

/* output prompt */
div.nboutput.container div.prompt pre {
    color: #BF5B3D;
}

/* all prompts */
div.nbinput.container div.prompt,
div.nboutput.container div.prompt {
    width: 4.5ex;
    padding-top: 5px;
    position: relative;
    user-select: none;
}

div.nbinput.container div.prompt > div,
div.nboutput.container div.prompt > div {
    position: absolute;
    right: 0;
    margin-right: 0.3ex;
}

@media (max-width: 540px) {
    div.nbinput.container div.prompt,
    div.nboutput.container div.prompt {
        width: unset;
        text-align: left;
        padding: 0.4em;
    }
    div.nboutput.container div.prompt.empty {
        padding: 0;
    }

    div.nbinput.container div.prompt > div,
    div.nboutput.container div.prompt > div {
        position: unset;
    }
}

/* disable scrollbars on prompts */
div.nbinput.container div.prompt pre,
div.nboutput.container div.prompt pre {
    overflow: hidden;
}

/* input/output area */
div.nbinput.container div.input_area,
div.nboutput.container div.output_area {
    -webkit-flex: 1;
    flex: 1;
    overflow: auto;
}
@media (max-width: 540px) {
    div.nbinput.container div.input_area,
    div.nboutput.container div.output_area {
        width: 100%;
    }
}

/* input area */
div.nbinput.container div.input_area {
    border: 1px solid #e0e0e0;
    border-radius: 2px;
    background: #f5f5f5;
}

/* override MathJax center alignment in output cells */
div.nboutput.container div[class*=MathJax] {
    text-align: left !important;
}

/* override sphinx.ext.imgmath center alignment in output cells */
div.nboutput.container div.math p {
    text-align: left;
}

/* standard error */
div.nboutput.container div.output_area.stderr {
    background: #fdd;
}

/* ANSI colors */
.ansi-black-fg { color: #3E424D; }
.ansi-black-bg { background-color: #3E424D; }
.ansi-black-intense-fg { color: #282C36; }
.ansi-black-intense-bg { background-color: #282C36; }
.ansi-red-fg { color: #E75C58; }
.ansi-red-bg { background-color: #E75C58; }
.ansi-red-intense-fg { color: #B22B31; }
.ansi-red-intense-bg { background-color: #B22B31; }
.ansi-green-fg { color: #00A250; }
.ansi-green-bg { background-color: #00A250; }
.ansi-green-intense-fg { color: #007427; }
.ansi-green-intense-bg { background-color: #007427; }
.ansi-yellow-fg { color: #DDB62B; }
.ansi-yellow-bg { background-color: #DDB62B; }
.ansi-yellow-intense-fg { color: #B27D12; }
.ansi-yellow-intense-bg { background-color: #B27D12; }
.ansi-blue-fg { color: #208FFB; }
.ansi-blue-bg { background-color: #208FFB; }
.ansi-blue-intense-fg { color: #0065CA; }
.ansi-blue-intense-bg { background-color: #0065CA; }
.ansi-magenta-fg { color: #D160C4; }
.ansi-magenta-bg { background-color: #D160C4; }
.ansi-magenta-intense-fg { color: #A03196; }
.ansi-magenta-intense-bg { background-color: #A03196; }
.ansi-cyan-fg { color: #60C6C8; }
.ansi-cyan-bg { background-color: #60C6C8; }
.ansi-cyan-intense-fg { color: #258F8F; }
.ansi-cyan-intense-bg { background-color: #258F8F; }
.ansi-white-fg { color: #C5C1B4; }
.ansi-white-bg { background-color: #C5C1B4; }
.ansi-white-intense-fg { color: #A1A6B2; }
.ansi-white-intense-bg { background-color: #A1A6B2; }

.ansi-default-inverse-fg { color: #FFFFFF; }
.ansi-default-inverse-bg { background-color: #000000; }

.ansi-bold { font-weight: bold; }
.ansi-underline { text-decoration: underline; }


div.nbinput.container div.input_area div[class*=highlight] > pre,
div.nboutput.container div.output_area div[class*=highlight] > pre,
div.nboutput.container div.output_area div[class*=highlight].math,
div.nboutput.container div.output_area.rendered_html,
div.nboutput.container div.output_area > div.output_javascript,
div.nboutput.container div.output_area:not(.rendered_html) > img{
    padding: 5px;
}

/* fix copybtn overflow problem in chromium (needed for 'sphinx_copybutton') */
div.nbinput.container div.input_area > div[class^='highlight'],
div.nboutput.container div.output_area > div[class^='highlight']{
    overflow-y: hidden;
}

/* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */
.prompt a.copybtn {
    display: none;
}

/* Some additional styling taken form the Jupyter notebook CSS */
div.rendered_html table {
  border: none;
  border-collapse: collapse;
  border-spacing: 0;
  color: black;
  font-size: 12px;
  table-layout: fixed;
}
div.rendered_html thead {
  border-bottom: 1px solid black;
  vertical-align: bottom;
}
div.rendered_html tr,
div.rendered_html th,
div.rendered_html td {
  text-align: right;
  vertical-align: middle;
  padding: 0.5em 0.5em;
  line-height: normal;
  white-space: normal;
  max-width: none;
  border: none;
}
div.rendered_html th {
  font-weight: bold;
}
div.rendered_html tbody tr:nth-child(odd) {
  background: #f5f5f5;
}
div.rendered_html tbody tr:hover {
  background: rgba(66, 165, 245, 0.2);
}
</style>
<div class="section" id="dislocation_SDVPN-calculation-style">
<h1>dislocation_SDVPN calculation style<a class="headerlink" href="#dislocation_SDVPN-calculation-style" title="Permalink to this headline">¶</a></h1>
<p><strong>Lucas M. Hale</strong>, <a class="reference external" href="mailto:lucas&#46;hale&#37;&#52;&#48;nist&#46;gov?Subject=ipr-demo">lucas<span>&#46;</span>hale<span>&#64;</span>nist<span>&#46;</span>gov</a>, <em>Materials Science and Engineering Division, NIST</em>.</p>
<div class="section" id="Introduction">
<h2>Introduction<a class="headerlink" href="#Introduction" title="Permalink to this headline">¶</a></h2>
<p>The dislocation_SDVPN calculation style predicts a dislocation’s planar spreading using the semidiscrete variational Peierls-Nabarro method. The solution finds the disregistry (difference in displacement above and below the slip plane) that minimizes the dislocation’s energy. The energy term consists of two primary components: an elastic component due to the dislocation interacting with itself, and a misfit component arising from the formation of a generalized stacking fault along the
dislocation’s spreading.</p>
<div class="section" id="Version-notes">
<h3>Version notes<a class="headerlink" href="#Version-notes" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><p>2018-09-25: Notebook added</p></li>
<li><p>2019-07-30: Notebook setup and parameters changed.</p></li>
<li><p>2020-09-22: Notebook updated to reflect changes in the calculation method due to updates in atomman’s Volterra class solution generators. Setup and parameter definitiions streamlined.</p></li>
</ul>
</div>
<div class="section" id="Additional-dependencies">
<h3>Additional dependencies<a class="headerlink" href="#Additional-dependencies" title="Permalink to this headline">¶</a></h3>
</div>
<div class="section" id="Disclaimers">
<h3>Disclaimers<a class="headerlink" href="#Disclaimers" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><p><a class="reference external" href="http://www.nist.gov/public_affairs/disclaimer.cfm">NIST disclaimers</a></p></li>
<li><p>The calculation method solves the problem using a 2D generalized stacking fault energy map. Better results may be possible by measuring a full 3D map, but that would require adding a new calculation for the 3D variation.</p></li>
<li><p>The implemented method is suited for dislocations with planar spreading. It is not suited for dislocations that spread on multiple atomic planes, like the a/2&lt;111&gt; bcc screw dislocation.</p></li>
<li><p>While the solution is taken at discrete points that (typically) correspond to atomic sites, the underlying method is still a continuum solution that does not fully account for the atomic nature of the dislocation.</p></li>
</ul>
</div>
</div>
<div class="section" id="Method-and-Theory">
<h2>Method and Theory<a class="headerlink" href="#Method-and-Theory" title="Permalink to this headline">¶</a></h2>
<p>This calculation method is a wrapper around the atomman.defect.SDVPN class. More details on the method and theory can be found in the <a class="reference external" href="https://www.ctcms.nist.gov/potentials/atomman/tutorial/04.4._Semidiscrete_Variational_Peierls-Nabarro.html">associated tutorial within the atomman documentation</a>.</p>
</div>
<div class="section" id="Demonstration">
<h2>Demonstration<a class="headerlink" href="#Demonstration" title="Permalink to this headline">¶</a></h2>
<div class="section" id="1.-Setup">
<h3>1. Setup<a class="headerlink" href="#1.-Setup" title="Permalink to this headline">¶</a></h3>
<div class="section" id="1.1.-Library-imports">
<h4>1.1. Library imports<a class="headerlink" href="#1.1.-Library-imports" title="Permalink to this headline">¶</a></h4>
<p>Import libraries needed by the calculation. The external libraries used are:</p>
<ul class="simple">
<li><p><a class="reference external" href="http://www.numpy.org/">numpy</a></p></li>
<li><p><a class="reference external" href="https://scipy.org/scipylib/">scipy</a></p></li>
<li><p><a class="reference external" href="https://matplotlib.org/">matplotlib</a></p></li>
<li><p><a class="reference external" href="https://github.com/usnistgov/atomman">atomman</a></p></li>
<li><p><a class="reference external" href="https://github.com/usnistgov/iprPy">iprPy</a></p></li>
</ul>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="c1"># Standard library imports</span>
<span class="kn">from</span> <span class="nn">pathlib</span> <span class="k">import</span> <span class="n">Path</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">datetime</span>
<span class="kn">from</span> <span class="nn">copy</span> <span class="k">import</span> <span class="n">deepcopy</span>

<span class="c1"># http://www.numpy.org/</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>

<span class="c1"># https://matplotlib.org/</span>
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
<span class="o">%</span><span class="k">matplotlib</span> inline

<span class="c1"># https://github.com/usnistgov/atomman</span>
<span class="kn">import</span> <span class="nn">atomman</span> <span class="k">as</span> <span class="nn">am</span>
<span class="kn">import</span> <span class="nn">atomman.lammps</span> <span class="k">as</span> <span class="nn">lmp</span>
<span class="kn">import</span> <span class="nn">atomman.unitconvert</span> <span class="k">as</span> <span class="nn">uc</span>

<span class="c1"># https://github.com/usnistgov/iprPy</span>
<span class="kn">import</span> <span class="nn">iprPy</span>

<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Notebook last executed on&#39;</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">date</span><span class="o">.</span><span class="n">today</span><span class="p">(),</span> <span class="s1">&#39;using iprPy version&#39;</span><span class="p">,</span> <span class="n">iprPy</span><span class="o">.</span><span class="n">__version__</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
Notebook last executed on 2020-09-22 using iprPy version 0.10.2
</pre></div></div>
</div>
</div>
<div class="section" id="1.2.-Default-calculation-setup">
<h4>1.2. Default calculation setup<a class="headerlink" href="#1.2.-Default-calculation-setup" title="Permalink to this headline">¶</a></h4>
<div class="nbinput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="c1"># Specify calculation style</span>
<span class="n">calc_style</span> <span class="o">=</span> <span class="s1">&#39;dislocation_SDVPN&#39;</span>

<span class="c1"># If workingdir is already set, then do nothing (already in correct folder)</span>
<span class="k">try</span><span class="p">:</span>
    <span class="n">workingdir</span> <span class="o">=</span> <span class="n">workingdir</span>

<span class="c1"># Change to workingdir if not already there</span>
<span class="k">except</span><span class="p">:</span>
    <span class="n">workingdir</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="s1">&#39;calculationfiles&#39;</span><span class="p">,</span> <span class="n">calc_style</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">workingdir</span><span class="o">.</span><span class="n">is_dir</span><span class="p">():</span>
        <span class="n">workingdir</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">parents</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
    <span class="n">os</span><span class="o">.</span><span class="n">chdir</span><span class="p">(</span><span class="n">workingdir</span><span class="p">)</span>

<span class="c1"># Initialize connection to library</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;C:/Users/lmh1/Documents/potentials_nist_gov/password.txt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
    <span class="n">user</span><span class="p">,</span> <span class="n">pswd</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
<span class="n">library</span> <span class="o">=</span> <span class="n">iprPy</span><span class="o">.</span><span class="n">Library</span><span class="p">(</span><span class="n">load</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;lammps_potentials&#39;</span><span class="p">],</span> <span class="n">username</span><span class="o">=</span><span class="n">user</span><span class="p">,</span> <span class="n">password</span><span class="o">=</span><span class="n">pswd</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="2.-Assign-values-for-the-calculation’s-run-parameters">
<h3>2. Assign values for the calculation’s run parameters<a class="headerlink" href="#2.-Assign-values-for-the-calculation’s-run-parameters" title="Permalink to this headline">¶</a></h3>
<div class="section" id="2.1.-Load-initial-unit-cell-system">
<h4>2.1. Load initial unit cell system<a class="headerlink" href="#2.1.-Load-initial-unit-cell-system" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><p><strong>ucell</strong> is an atomman.System representing a fundamental unit cell of the system (required). Here, this is loaded from the database for the prototype.</p></li>
</ul>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="c1"># Create ucell by loading prototype record</span>
<span class="n">ucell</span> <span class="o">=</span> <span class="n">am</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="s1">&#39;crystal&#39;</span><span class="p">,</span> <span class="n">potential_LAMMPS_id</span><span class="o">=</span><span class="s1">&#39;1999--Mishin-Y--Ni--LAMMPS--ipr1&#39;</span><span class="p">,</span> <span class="n">family</span><span class="o">=</span><span class="s1">&#39;A1--Cu--fcc&#39;</span><span class="p">,</span> <span class="n">database</span><span class="o">=</span><span class="n">library</span><span class="p">)</span>

<span class="nb">print</span><span class="p">(</span><span class="n">ucell</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
avect =  [ 3.520,  0.000,  0.000]
bvect =  [ 0.000,  3.520,  0.000]
cvect =  [ 0.000,  0.000,  3.520]
origin = [ 0.000,  0.000,  0.000]
natoms = 4
natypes = 1
symbols = (&#39;Ni&#39;,)
pbc = [ True  True  True]
per-atom properties = [&#39;atype&#39;, &#39;pos&#39;]
     id |   atype |  pos[0] |  pos[1] |  pos[2]
      0 |       1 |   0.000 |   0.000 |   0.000
      1 |       1 |   0.000 |   1.760 |   1.760
      2 |       1 |   1.760 |   0.000 |   1.760
      3 |       1 |   1.760 |   1.760 |   0.000
</pre></div></div>
</div>
</div>
<div class="section" id="2.2-Specify-material-elastic-constants">
<h4>2.2 Specify material elastic constants<a class="headerlink" href="#2.2-Specify-material-elastic-constants" title="Permalink to this headline">¶</a></h4>
<p>Simple input parameters:</p>
<ul class="simple">
<li><p><strong>C_dict</strong> is a dictionary containing the unique elastic constants for the potential and crystal structure defined above.</p></li>
</ul>
<p>Derived parameters</p>
<ul class="simple">
<li><p><strong>C</strong> is an atomman.ElasticConstants object built from C_dict.</p></li>
</ul>
<div class="nbinput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">C_dict</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">C_dict</span><span class="p">[</span><span class="s1">&#39;C11&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">uc</span><span class="o">.</span><span class="n">set_in_units</span><span class="p">(</span><span class="mf">247.86</span><span class="p">,</span> <span class="s1">&#39;GPa&#39;</span><span class="p">)</span>
<span class="n">C_dict</span><span class="p">[</span><span class="s1">&#39;C12&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">uc</span><span class="o">.</span><span class="n">set_in_units</span><span class="p">(</span><span class="mf">147.83</span><span class="p">,</span> <span class="s1">&#39;GPa&#39;</span><span class="p">)</span>
<span class="n">C_dict</span><span class="p">[</span><span class="s1">&#39;C44&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">uc</span><span class="o">.</span><span class="n">set_in_units</span><span class="p">(</span><span class="mf">124.84</span><span class="p">,</span> <span class="s1">&#39;GPa&#39;</span><span class="p">)</span>

<span class="c1"># -------------- Derived parameters -------------- #</span>
<span class="c1"># Build ElasticConstants object from C_dict terms</span>
<span class="n">C</span> <span class="o">=</span> <span class="n">am</span><span class="o">.</span><span class="n">ElasticConstants</span><span class="p">(</span><span class="o">**</span><span class="n">C_dict</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="2.3-Specify-the-defect-parameters">
<h4>2.3 Specify the defect parameters<a class="headerlink" href="#2.3-Specify-the-defect-parameters" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><p><strong>gammasurface_file</strong> gives the path to a data model file containing 2D gamma surface results. This can be a calc_stacking_fault_map_2D record.</p></li>
<li><p><strong>burgers</strong> is the crystallographic Miller Burgers vector for the dislocation.</p></li>
<li><p><strong>ξ_uvw</strong> is the Miller [uvw] line vector direction for the dislocation. The angle between burgers and ξ_uvw determines the dislocation’s character</p></li>
<li><p><strong>slip_hkl</strong> is the Miller (hkl) slip plane for the dislocation.</p></li>
<li><p><strong>m</strong> is the Cartesian vector of the final system that the dislocation solution’s m vector (in-plane, perpendicular to ξ) should align with. Limited to being parallel to one of the three Cartesian axes.</p></li>
<li><p><strong>n</strong> is the Cartesian vector of the final system that the dislocation solution’s n vector (slip plane normal) should align with. Limited to being parallel to one of the three Cartesian axes.</p></li>
<li><p><strong>gamma</strong> is a GammaSurface object. Here, it is loaded from gammasurface_file. Note that gamma and volterra must be for the same plane.</p></li>
<li><p><strong>volterra</strong> is a VolterraDislocation object for the dislocation type of interest. Here, it is created based on the elastic constants, unit cell and dislocation parameters above. Note that gamma and volterra must be for the same plane.</p></li>
</ul>
<div class="nbinput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">gammasurface_file</span> <span class="o">=</span> <span class="s1">&#39;../stacking_fault_map_2D/gamma.json&#39;</span>
<span class="n">gamma</span> <span class="o">=</span> <span class="n">am</span><span class="o">.</span><span class="n">defect</span><span class="o">.</span><span class="n">GammaSurface</span><span class="p">(</span><span class="n">model</span><span class="o">=</span><span class="n">gammasurface_file</span><span class="p">)</span>

<span class="c1"># fcc a/2 &lt;110&gt;{111} dislocations</span>
<span class="n">burgers</span> <span class="o">=</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span> <span class="mf">1.</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.</span><span class="p">,</span> <span class="mf">0.</span><span class="p">])</span>
<span class="n">slip_hkl</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span>

<span class="c1"># Line direction determines dislocation character</span>
<span class="n">ξ_uvw</span> <span class="o">=</span> <span class="p">[</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span> <span class="c1"># 90 degree edge</span>
<span class="c1">#ξ_uvw = [ 1, 0,-1] # 60 degree mixed</span>
<span class="c1">#ξ_uvw = [ 1,-2, 1] # 30 degree mixed</span>
<span class="c1">#ξ_uvw = [ 1,-1, 0] # 0 degree screw</span>

<span class="c1"># Best choice for m + n as it works for non-cubic systems</span>
<span class="n">m</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span>
<span class="n">n</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">]</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="2.4-Specify-calculation-specific-run-parameters">
<h4>2.4 Specify calculation-specific run parameters<a class="headerlink" href="#2.4-Specify-calculation-specific-run-parameters" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><p><strong>xmax</strong>: The maximum value of the x-coordinates to use for the points where the disregistry is evaluated. The solution is centered around x=0, therefore this also corresponds to the minimum value of x used. The set of x-coordinates used is fully defined by giving at least two of xmax, xstep and xnum.</p></li>
<li><p><strong>xstep</strong>: The step size (delta x) value between the x-coordinates used to evaluate the disregistry. The set of x-coordinates used is fully defined by giving at least two of xmax, xstep and xnum.</p></li>
<li><p><strong>xnum</strong>: The total number of x-coordinates at which to evaluate the disregistry. The set of x-coordinates used is fully defined by giving at least two of xmax, xstep and xnum.</p></li>
<li><p><strong>min_method</strong>: The scipy.optimize.minimize method style to use when solving for the disregistry. Default value is ‘Powell’, which seems to do decently well for this problem.</p></li>
<li><p><strong>min_options</strong>: Allows for the specification of the options dictionary used by scipy.optimize.minimize. This is given as “key value key value…”.</p></li>
<li><p><strong>min_cycles</strong>: Specifies the number of times to run the minimization in succession. The minimization algorithms used by the underlying scipy code often benefit from restarting and rerunning the minimized configuration to achive a better fit. Default value is 10.</p></li>
<li><p><strong>cutofflongrange</strong>: The radial cutoff (in distance units) to use for the long-range elastic energy. The long-range elastic energy is configuration-independent, so this value changes the dislocation’s energy but not the computed disregistry profile. Default value is 1000 Angstroms.</p></li>
<li><p><strong>tau_xy</strong>: Shear stress (in units of pressure) to apply to the system. Default value is 0 GPa.</p></li>
<li><p><strong>tau_yy</strong>: Normal stress (in units of pressure) to apply to the system. Default value is 0 GPa.</p></li>
<li><p><strong>tau_yz</strong>: Shear stress (in units of pressure) to apply to the system. Default value is 0 GPa.</p></li>
<li><p><strong>alpha</strong>: Coefficient(s) (in pressure/length units) of the non-local energy correction term to use. Default value is 0.0, meaning this correction is not applied.</p></li>
<li><p><strong>beta_xx, beta_yy, beta_zz, beta_xy, beta_xz, beta_yz</strong>: Components of the surface energy coefficient tensor (in units pressure-length) to use. Default value is 0.0 GPa-Angstrom for all, meaning this correction is not applied.</p></li>
<li><p><strong>cdiffelastic, cdiffsurface, cdiffstress</strong>: Booleans indicating how the dislocation density (derivative of disregistry) is computed within the elastic, surface and stress terms, respectively. If True, central difference is used, otherwise only the change between the current and previous points is used. Default values are True for cdiffsurface, and False for the other two.</p></li>
<li><p><strong>halfwidth</strong>: The arctan disregistry halfwidth (in length units) to use for creating the initial disregistry guess.</p></li>
<li><p><strong>normalizedisreg</strong>: Boolean indicating how the disregistry profile is handled. If True (default), the disregistry is scaled such that the minimum x value has a disregistry of 0 and the maximum x value has a disregistry equal to the dislocation’s Burgers vector. Note that the disregistry for these endpoints is fixed, so if you use False the initial disregistry should be close to the final solution.</p></li>
<li><p><strong>fullstress</strong>: Boolean indicating which of two stress formulas to use. True uses the original full formulation, while False uses a newer, simpler representation. Default value is True.</p></li>
</ul>
<div class="nbinput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">xmax</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">xstep</span> <span class="o">=</span> <span class="mi">1</span><span class="o">/</span><span class="mi">5</span>
<span class="n">xnum</span> <span class="o">=</span> <span class="mi">200</span>
<span class="n">xscale</span> <span class="o">=</span> <span class="kc">True</span>

<span class="n">min_method</span> <span class="o">=</span> <span class="s1">&#39;Powell&#39;</span>
<span class="n">min_options</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">min_options</span><span class="p">[</span><span class="s1">&#39;disp&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> <span class="c1"># will display convergence info</span>
<span class="n">min_options</span><span class="p">[</span><span class="s1">&#39;xtol&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">1e-6</span> <span class="c1"># smaller convergence tolerance than default</span>
<span class="n">min_options</span><span class="p">[</span><span class="s1">&#39;ftol&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">1e-6</span> <span class="c1"># smaller convergence tolerance than default</span>
<span class="c1">#min_options[&#39;maxiter&#39;] = 2 # for testing purposes</span>
<span class="n">min_cycles</span> <span class="o">=</span> <span class="mi">10</span>

<span class="n">cutofflongrange</span> <span class="o">=</span> <span class="n">uc</span><span class="o">.</span><span class="n">set_in_units</span><span class="p">(</span><span class="mi">1000</span><span class="p">,</span> <span class="s1">&#39;angstrom&#39;</span><span class="p">)</span>
<span class="n">halfwidth</span> <span class="o">=</span> <span class="n">uc</span><span class="o">.</span><span class="n">set_in_units</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="s1">&#39;angstrom&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="3.-Define-calculation-function(s)">
<h3>3. Define calculation function(s)<a class="headerlink" href="#3.-Define-calculation-function(s)" title="Permalink to this headline">¶</a></h3>
<div class="section" id="3.1.-peierlsnabarro()">
<h4>3.1. peierlsnabarro()<a class="headerlink" href="#3.1.-peierlsnabarro()" title="Permalink to this headline">¶</a></h4>
<div class="nbinput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[7]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="k">def</span> <span class="nf">peierlsnabarro</span><span class="p">(</span><span class="n">ucell</span><span class="p">,</span> <span class="n">C</span><span class="p">,</span> <span class="n">burgers</span><span class="p">,</span> <span class="n">ξ_uvw</span><span class="p">,</span> <span class="n">slip_hkl</span><span class="p">,</span> <span class="n">gamma</span><span class="p">,</span>
                   <span class="n">m</span><span class="o">=</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">],</span> <span class="n">n</span><span class="o">=</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">],</span>
                   <span class="n">cutofflongrange</span><span class="o">=</span><span class="n">uc</span><span class="o">.</span><span class="n">set_in_units</span><span class="p">(</span><span class="mi">1000</span><span class="p">,</span> <span class="s1">&#39;angstrom&#39;</span><span class="p">),</span>
                   <span class="n">tau</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">)),</span> <span class="n">alpha</span><span class="o">=</span><span class="p">[</span><span class="mf">0.0</span><span class="p">],</span> <span class="n">beta</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">)),</span>
                   <span class="n">cdiffelastic</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">cdiffsurface</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">cdiffstress</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                   <span class="n">fullstress</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                   <span class="n">halfwidth</span><span class="o">=</span><span class="n">uc</span><span class="o">.</span><span class="n">set_in_units</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;angstrom&#39;</span><span class="p">),</span>
                   <span class="n">normalizedisreg</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                   <span class="n">xnum</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">xmax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">xstep</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">xscale</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                   <span class="n">min_method</span><span class="o">=</span><span class="s1">&#39;Powell&#39;</span><span class="p">,</span> <span class="n">min_options</span><span class="o">=</span><span class="p">{},</span> <span class="n">min_cycles</span><span class="o">=</span><span class="mi">10</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Solves a Peierls-Nabarro dislocation model.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    ucell : atomman.System</span>
<span class="sd">        The unit cell to use as the seed for the dislocation system.  Note that</span>
<span class="sd">        only box information is used and not atomic positions.</span>
<span class="sd">    C : atomman.ElasticConstants</span>
<span class="sd">        The elastic constants associated with the bulk crystal structure</span>
<span class="sd">        for ucell.</span>
<span class="sd">    burgers : array-like object</span>
<span class="sd">        The dislocation&#39;s Burgers vector given as a Miller or</span>
<span class="sd">        Miller-Bravais vector relative to ucell.</span>
<span class="sd">    ξ_uvw : array-like object</span>
<span class="sd">        The dislocation&#39;s line direction given as a Miller or</span>
<span class="sd">        Miller-Bravais vector relative to ucell.</span>
<span class="sd">    slip_hkl : array-like object</span>
<span class="sd">        The dislocation&#39;s slip plane given as a Miller or Miller-Bravais</span>
<span class="sd">        plane relative to ucell.</span>
<span class="sd">    m : array-like object, optional</span>
<span class="sd">        The m unit vector for the dislocation solution.  m, n, and ξ</span>
<span class="sd">        (dislocation line) should be right-hand orthogonal.  Default value</span>
<span class="sd">        is [0,1,0] (y-axis).</span>
<span class="sd">    n : array-like object, optional</span>
<span class="sd">        The n unit vector for the dislocation solution.  m, n, and ξ</span>
<span class="sd">        (dislocation line) should be right-hand orthogonal.  Default value</span>
<span class="sd">        is [0,0,1] (z-axis). n is normal to the dislocation slip plane.</span>
<span class="sd">    cutofflongrange : float, optional</span>
<span class="sd">        The cutoff distance to use for computing the long-range energy.</span>
<span class="sd">        Default value is 1000 angstroms.</span>
<span class="sd">    tau : numpy.ndarray, optional</span>
<span class="sd">        A (3,3) array giving the stress tensor to apply to the system</span>
<span class="sd">        using the stress energy term.  Only the xy, yy, and yz components</span>
<span class="sd">        are used.  Default value is all zeros.</span>
<span class="sd">    alpha : list of float, optional</span>
<span class="sd">        The alpha coefficient(s) used by the nonlocal energy term.  Default</span>
<span class="sd">        value is [0.0].</span>
<span class="sd">    beta : numpy.ndarray, optional</span>
<span class="sd">        The (3,3) array of beta coefficient(s) used by the surface energy</span>
<span class="sd">        term.  Default value is all zeros.</span>
<span class="sd">    cdiffelastic : bool, optional</span>
<span class="sd">        Flag indicating if the dislocation density for the elastic energy</span>
<span class="sd">        component is computed with central difference (True) or simply</span>
<span class="sd">        neighboring values (False).  Default value is False.</span>
<span class="sd">    cdiffsurface : bool, optional</span>
<span class="sd">        Flag indicating if the dislocation density for the surface energy</span>
<span class="sd">        component is computed with central difference (True) or simply</span>
<span class="sd">        neighboring values (False).  Default value is True.</span>
<span class="sd">    cdiffstress : bool, optional</span>
<span class="sd">        Flag indicating if the dislocation density for the stress energy</span>
<span class="sd">        component is computed with central difference (True) or simply</span>
<span class="sd">        neighboring values (False).  Only matters if fullstress is True.</span>
<span class="sd">        Default value is False.</span>
<span class="sd">    fullstress : bool, optional</span>
<span class="sd">        Flag indicating which stress energy algorithm to use.  Default</span>
<span class="sd">        value is True.</span>
<span class="sd">    halfwidth : float, optional</span>
<span class="sd">        A dislocation halfwidth guess to use for generating the initial</span>
<span class="sd">        disregistry guess.  Does not have to be accurate, but the better the</span>
<span class="sd">        guess the fewer minimization steps will likely be needed.  Default</span>
<span class="sd">        value is 1 Angstrom.</span>
<span class="sd">    normalizedisreg : bool, optional</span>
<span class="sd">        If True, the initial disregistry guess will be scaled such that it</span>
<span class="sd">        will have a value of 0 at the minimum x and a value of burgers at the</span>
<span class="sd">        maximum x.  Default value is True.  Note: the disregistry of end points</span>
<span class="sd">        are fixed, thus True is usually preferential.</span>
<span class="sd">    xnum :  int, optional</span>
<span class="sd">        The number of x value points to use for the solution.  Two of xnum,</span>
<span class="sd">        xmax, and xstep must be given.</span>
<span class="sd">    xmax : float, optional</span>
<span class="sd">        The maximum value of x to use.  Note that the minimum x value will be</span>
<span class="sd">        -xmax, thus the range of x will be twice xmax.  Two of xnum, xmax, and</span>
<span class="sd">        xstep must be given.</span>
<span class="sd">    xstep : float, optional</span>
<span class="sd">        The delta x value to use, i.e. the step size between the x values used.</span>
<span class="sd">        Two of xnum, xmax, and xstep must be given.</span>
<span class="sd">    xscale : bool, optional</span>
<span class="sd">        Flag indicating if xmax and/or xstep values are to be taken as absolute</span>
<span class="sd">        or relative to ucell&#39;s a lattice parameter.  Default value is False,</span>
<span class="sd">        i.e. the x parameters are absolute and not scaled.</span>
<span class="sd">    min_method : str, optional</span>
<span class="sd">        The scipy.optimize.minimize method to use.  Default value is</span>
<span class="sd">        &#39;Powell&#39;.</span>
<span class="sd">    min_options : dict, optional</span>
<span class="sd">        Any options to pass on to scipy.optimize.minimize. Default value</span>
<span class="sd">        is {}.</span>
<span class="sd">    min_cycles : int, optional</span>
<span class="sd">        The number of minimization runs to perform on the system.  Restarting</span>
<span class="sd">        after obtaining a solution can help further refine to the best pathway.</span>
<span class="sd">        Default value is 10.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="c1"># Solve Volterra dislocation</span>
    <span class="n">volterra</span> <span class="o">=</span> <span class="n">am</span><span class="o">.</span><span class="n">defect</span><span class="o">.</span><span class="n">solve_volterra_dislocation</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="n">burgers</span><span class="p">,</span> <span class="n">ξ_uvw</span><span class="o">=</span><span class="n">ξ_uvw</span><span class="p">,</span>
                                                    <span class="n">slip_hkl</span><span class="o">=</span><span class="n">slip_hkl</span><span class="p">,</span> <span class="n">box</span><span class="o">=</span><span class="n">ucell</span><span class="o">.</span><span class="n">box</span><span class="p">,</span>
                                                    <span class="n">m</span><span class="o">=</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="o">=</span><span class="n">n</span><span class="p">)</span>

    <span class="c1"># Generate SDVPN object</span>
    <span class="n">pnsolution</span> <span class="o">=</span> <span class="n">am</span><span class="o">.</span><span class="n">defect</span><span class="o">.</span><span class="n">SDVPN</span><span class="p">(</span><span class="n">volterra</span><span class="o">=</span><span class="n">volterra</span><span class="p">,</span> <span class="n">gamma</span><span class="o">=</span><span class="n">gamma</span><span class="p">,</span>
                                 <span class="n">tau</span><span class="o">=</span><span class="n">tau</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="n">alpha</span><span class="p">,</span> <span class="n">beta</span><span class="o">=</span><span class="n">beta</span><span class="p">,</span>
                                 <span class="n">cutofflongrange</span><span class="o">=</span><span class="n">cutofflongrange</span><span class="p">,</span>
                                 <span class="n">fullstress</span><span class="o">=</span><span class="n">fullstress</span><span class="p">,</span> <span class="n">cdiffelastic</span><span class="o">=</span><span class="n">cdiffelastic</span><span class="p">,</span>
                                 <span class="n">cdiffsurface</span><span class="o">=</span><span class="n">cdiffsurface</span><span class="p">,</span> <span class="n">cdiffstress</span><span class="o">=</span><span class="n">cdiffstress</span><span class="p">,</span>
                                 <span class="n">min_method</span><span class="o">=</span><span class="n">min_method</span><span class="p">,</span> <span class="n">min_options</span><span class="o">=</span><span class="n">min_options</span><span class="p">)</span>

    <span class="c1"># Scale xmax and xstep by alat</span>
    <span class="k">if</span> <span class="n">xscale</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">xmax</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">xmax</span> <span class="o">*=</span> <span class="n">ucell</span><span class="o">.</span><span class="n">box</span><span class="o">.</span><span class="n">a</span>
        <span class="k">if</span> <span class="n">xstep</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">xstep</span> <span class="o">*=</span> <span class="n">ucell</span><span class="o">.</span><span class="n">box</span><span class="o">.</span><span class="n">a</span>

    <span class="c1"># Generate initial disregistry guess</span>
    <span class="n">x</span><span class="p">,</span> <span class="n">idisreg</span> <span class="o">=</span> <span class="n">am</span><span class="o">.</span><span class="n">defect</span><span class="o">.</span><span class="n">pn_arctan_disregistry</span><span class="p">(</span><span class="n">xmax</span><span class="o">=</span><span class="n">xmax</span><span class="p">,</span> <span class="n">xstep</span><span class="o">=</span><span class="n">xstep</span><span class="p">,</span> <span class="n">xnum</span><span class="o">=</span><span class="n">xnum</span><span class="p">,</span>
                                                 <span class="n">burgers</span><span class="o">=</span><span class="n">pnsolution</span><span class="o">.</span><span class="n">burgers</span><span class="p">,</span>
                                                 <span class="n">halfwidth</span><span class="o">=</span><span class="n">halfwidth</span><span class="p">,</span>
                                                 <span class="n">normalize</span><span class="o">=</span><span class="n">normalizedisreg</span><span class="p">)</span>

    <span class="c1"># Set up loop parameters</span>
    <span class="n">cycle</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">disregistries</span> <span class="o">=</span> <span class="p">[</span><span class="n">idisreg</span><span class="p">]</span>
    <span class="n">minimization_energies</span> <span class="o">=</span> <span class="p">[</span><span class="n">pnsolution</span><span class="o">.</span><span class="n">total_energy</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">idisreg</span><span class="p">)]</span>

    <span class="c1"># Run minimization for min_cycles</span>
    <span class="n">pnsolution</span><span class="o">.</span><span class="n">x</span> <span class="o">=</span> <span class="n">x</span>
    <span class="n">pnsolution</span><span class="o">.</span><span class="n">disregistry</span> <span class="o">=</span> <span class="n">idisreg</span>
    <span class="k">while</span> <span class="n">cycle</span> <span class="o">&lt;</span> <span class="n">min_cycles</span><span class="p">:</span>
        <span class="n">cycle</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="n">pnsolution</span><span class="o">.</span><span class="n">solve</span><span class="p">()</span>
        <span class="n">disregistries</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">pnsolution</span><span class="o">.</span><span class="n">disregistry</span><span class="p">)</span>
        <span class="n">minimization_energies</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">pnsolution</span><span class="o">.</span><span class="n">total_energy</span><span class="p">())</span>

    <span class="c1"># Initialize results dict</span>
    <span class="n">results_dict</span> <span class="o">=</span> <span class="p">{}</span>
    <span class="n">results_dict</span><span class="p">[</span><span class="s1">&#39;SDVPN_solution&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">pnsolution</span>
    <span class="n">results_dict</span><span class="p">[</span><span class="s1">&#39;minimization_energies&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">minimization_energies</span>
    <span class="n">results_dict</span><span class="p">[</span><span class="s1">&#39;disregistry_profiles&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">disregistries</span>

    <span class="k">return</span> <span class="n">results_dict</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="4.-Run-calculation-function(s)">
<h3>4. Run calculation function(s)<a class="headerlink" href="#4.-Run-calculation-function(s)" title="Permalink to this headline">¶</a></h3>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[8]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">results_dict</span> <span class="o">=</span> <span class="n">peierlsnabarro</span><span class="p">(</span><span class="n">ucell</span><span class="p">,</span> <span class="n">C</span><span class="p">,</span> <span class="n">burgers</span><span class="p">,</span> <span class="n">ξ_uvw</span><span class="p">,</span> <span class="n">slip_hkl</span><span class="p">,</span> <span class="n">gamma</span><span class="p">,</span>
                              <span class="n">m</span> <span class="o">=</span> <span class="n">m</span><span class="p">,</span>
                              <span class="n">n</span> <span class="o">=</span> <span class="n">n</span><span class="p">,</span>
                              <span class="n">cutofflongrange</span> <span class="o">=</span> <span class="n">cutofflongrange</span><span class="p">,</span>
                              <span class="c1">#tau = tau,</span>
                              <span class="c1">#alpha = alpha,</span>
                              <span class="c1">#beta = beta,</span>
                              <span class="c1">#cdiffelastic = cdiffelastic,</span>
                              <span class="c1">#cdiffsurface = cdiffsurface,</span>
                              <span class="c1">#cdiffstress = cdiffstress,</span>
                              <span class="c1">#fullstress = fullstress,</span>
                              <span class="n">halfwidth</span> <span class="o">=</span> <span class="n">halfwidth</span><span class="p">,</span>
                              <span class="c1">#normalizedisreg = normalizedisreg,</span>
                              <span class="n">xnum</span> <span class="o">=</span> <span class="n">xnum</span><span class="p">,</span>
                              <span class="n">xstep</span> <span class="o">=</span> <span class="n">xstep</span><span class="p">,</span>
                              <span class="n">xmax</span> <span class="o">=</span> <span class="n">xmax</span><span class="p">,</span>
                              <span class="n">xscale</span> <span class="o">=</span> <span class="n">xscale</span><span class="p">,</span>
                              <span class="n">min_method</span> <span class="o">=</span> <span class="n">min_method</span><span class="p">,</span>
                              <span class="n">min_options</span> <span class="o">=</span> <span class="n">min_options</span><span class="p">,</span>
                              <span class="n">min_cycles</span> <span class="o">=</span> <span class="n">min_cycles</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
Optimization terminated successfully.
         Current function value: 4.905269
         Iterations: 25
         Function evaluations: 170079
Optimization terminated successfully.
         Current function value: 4.905263
         Iterations: 2
         Function evaluations: 16436
Optimization terminated successfully.
         Current function value: 4.905263
         Iterations: 1
         Function evaluations: 8635
Optimization terminated successfully.
         Current function value: 4.905263
         Iterations: 1
         Function evaluations: 8857
Optimization terminated successfully.
         Current function value: 4.905263
         Iterations: 1
         Function evaluations: 8994
Optimization terminated successfully.
         Current function value: 4.905263
         Iterations: 1
         Function evaluations: 9031
Optimization terminated successfully.
         Current function value: 4.905263
         Iterations: 1
         Function evaluations: 8931
Optimization terminated successfully.
         Current function value: 4.905263
         Iterations: 1
         Function evaluations: 9163
Optimization terminated successfully.
         Current function value: 4.905263
         Iterations: 1
         Function evaluations: 8961
Optimization terminated successfully.
         Current function value: 4.905263
         Iterations: 1
         Function evaluations: 8952
</pre></div></div>
</div>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[9]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">results_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[9]:
</pre></div>
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
dict_keys([&#39;SDVPN_solution&#39;, &#39;minimization_energies&#39;, &#39;disregistry_profiles&#39;])
</pre></div></div>
</div>
</div>
<div class="section" id="5.-Report-results">
<h3>5. Report results<a class="headerlink" href="#5.-Report-results" title="Permalink to this headline">¶</a></h3>
<div class="section" id="5.1-Define-units-for-outputting-values">
<h4>5.1 Define units for outputting values<a class="headerlink" href="#5.1-Define-units-for-outputting-values" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><p><strong>length_unit</strong> is the unit of length to display results in.</p></li>
<li><p><strong>energy_per_length_unit</strong> is the unit of energy per length to display dislocation energies in.</p></li>
</ul>
<div class="nbinput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[10]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">length_unit</span> <span class="o">=</span> <span class="s1">&#39;angstrom&#39;</span>
<span class="n">energyperlength_unit</span> <span class="o">=</span> <span class="s1">&#39;eV/angstrom&#39;</span>
<span class="n">energyperarea_unit</span> <span class="o">=</span> <span class="s1">&#39;mJ/m^2&#39;</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="5.2-Solution">
<h4>5.2 Solution<a class="headerlink" href="#5.2-Solution" title="Permalink to this headline">¶</a></h4>
<p>SDVPN_solution in the results dictionary is an am.Defect.SDVPN object which contains the final disregistry information.</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[11]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">results_dict</span><span class="p">[</span><span class="s1">&#39;SDVPN_solution&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">disregistry_plot</span><span class="p">(</span><span class="n">length_unit</span><span class="o">=</span><span class="n">length_unit</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<img alt="../_images/notebook_dislocation_SDVPN_28_0.png" src="../_images/notebook_dislocation_SDVPN_28_0.png" />
</div>
</div>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[12]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">results_dict</span><span class="p">[</span><span class="s1">&#39;SDVPN_solution&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">E_gsf_surface_plot</span><span class="p">(</span><span class="n">length_unit</span><span class="o">=</span><span class="n">length_unit</span><span class="p">,</span> <span class="n">energyperarea_unit</span><span class="o">=</span><span class="n">energyperarea_unit</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<img alt="../_images/notebook_dislocation_SDVPN_29_0.png" src="../_images/notebook_dislocation_SDVPN_29_0.png" />
</div>
</div>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[13]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">results_dict</span><span class="p">[</span><span class="s1">&#39;SDVPN_solution&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">E_gsf_vs_x_plot</span><span class="p">(</span><span class="n">length_unit</span><span class="o">=</span><span class="n">length_unit</span><span class="p">,</span> <span class="n">energyperarea_unit</span><span class="o">=</span><span class="n">energyperarea_unit</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<img alt="../_images/notebook_dislocation_SDVPN_30_0.png" src="../_images/notebook_dislocation_SDVPN_30_0.png" />
</div>
</div>
</div>
<div class="section" id="5.3-Minimum-energy-per-cycle">
<h4>5.3 Minimum energy per cycle<a class="headerlink" href="#5.3-Minimum-energy-per-cycle" title="Permalink to this headline">¶</a></h4>
<p>minimization_energies in the results dict lists the total computed dislocation energy for the initial disregistry and after each minimization run.</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[14]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Total dislocation energy per minimization run (in </span><span class="si">%s</span><span class="s1">):&#39;</span> <span class="o">%</span> <span class="n">energyperlength_unit</span><span class="p">)</span>
<span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">E_total</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">results_dict</span><span class="p">[</span><span class="s1">&#39;minimization_energies&#39;</span><span class="p">]):</span>
    <span class="nb">print</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">uc</span><span class="o">.</span><span class="n">get_in_units</span><span class="p">(</span><span class="n">E_total</span><span class="p">,</span> <span class="n">energyperlength_unit</span><span class="p">))</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
Total dislocation energy per minimization run (in eV/angstrom):
0 5.344452611702839
1 4.905268833729996
2 4.90526343054055
3 4.90526328741267
4 4.905263191449777
5 4.905263106389016
6 4.9052630221379605
7 4.9052629360389375
8 4.9052628475353695
9 4.905262756612204
10 4.905262663339871
</pre></div></div>
</div>
</div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">dislocation_SDVPN calculation style</a><ul>
<li><a class="reference internal" href="#Introduction">Introduction</a><ul>
<li><a class="reference internal" href="#Version-notes">Version notes</a></li>
<li><a class="reference internal" href="#Additional-dependencies">Additional dependencies</a></li>
<li><a class="reference internal" href="#Disclaimers">Disclaimers</a></li>
</ul>
</li>
<li><a class="reference internal" href="#Method-and-Theory">Method and Theory</a></li>
<li><a class="reference internal" href="#Demonstration">Demonstration</a><ul>
<li><a class="reference internal" href="#1.-Setup">1. Setup</a><ul>
<li><a class="reference internal" href="#1.1.-Library-imports">1.1. Library imports</a></li>
<li><a class="reference internal" href="#1.2.-Default-calculation-setup">1.2. Default calculation setup</a></li>
</ul>
</li>
<li><a class="reference internal" href="#2.-Assign-values-for-the-calculation’s-run-parameters">2. Assign values for the calculation’s run parameters</a><ul>
<li><a class="reference internal" href="#2.1.-Load-initial-unit-cell-system">2.1. Load initial unit cell system</a></li>
<li><a class="reference internal" href="#2.2-Specify-material-elastic-constants">2.2 Specify material elastic constants</a></li>
<li><a class="reference internal" href="#2.3-Specify-the-defect-parameters">2.3 Specify the defect parameters</a></li>
<li><a class="reference internal" href="#2.4-Specify-calculation-specific-run-parameters">2.4 Specify calculation-specific run parameters</a></li>
</ul>
</li>
<li><a class="reference internal" href="#3.-Define-calculation-function(s)">3. Define calculation function(s)</a><ul>
<li><a class="reference internal" href="#3.1.-peierlsnabarro()">3.1. peierlsnabarro()</a></li>
</ul>
</li>
<li><a class="reference internal" href="#4.-Run-calculation-function(s)">4. Run calculation function(s)</a></li>
<li><a class="reference internal" href="#5.-Report-results">5. Report results</a><ul>
<li><a class="reference internal" href="#5.1-Define-units-for-outputting-values">5.1 Define units for outputting values</a></li>
<li><a class="reference internal" href="#5.2-Solution">5.2 Solution</a></li>
<li><a class="reference internal" href="#5.3-Minimum-energy-per-cycle">5.3 Minimum energy per cycle</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="diatom_scan.html"
                        title="previous chapter">diatom_scan calculation style</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="dislocation_monopole.html"
                        title="next chapter">dislocation_monopole calculation style</a></p>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="dislocation_monopole.html" title="dislocation_monopole calculation style"
             >next</a> |</li>
        <li class="right" >
          <a href="diatom_scan.html" title="diatom_scan calculation style"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">iprPy 0.10.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../notebook_styles.html" >Jupyter Demonstration Notebooks</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.1.2.
    </div>
  </body>
</html>